#!/usr/bin/expect

spawn build/bin/observer -f etc/observer.ini -P cli 
expect "miniob >"
send "DROP TABLE join_table_1;\r"
expect "miniob >"
send "DROP TABLE join_table_2;\r"
expect "miniob >"
send "DROP TABLE join_table_3;\r"
expect "miniob >"
send "DROP TABLE join_table_empty_1;\r"
expect "miniob >"
send "DROP TABLE join_table_empty_2;\r"
expect "miniob >"
send "CREATE TABLE join_table_1(id int, name char);\r"
expect "miniob >"
send "CREATE TABLE join_table_2(id int, num int);\r"
expect "miniob >"
send "CREATE TABLE join_table_3(id int, num2 int);\r"
expect "miniob >"
send "create table join_table_empty_1(id int, num_empty_1 int);\r"
expect "miniob >"
send "create table join_table_empty_2(id int, num_empty_2 int);\r"
expect "miniob >"
send "INSERT INTO join_table_1 VALUES (1, 'a');\r"
expect "miniob >"
send "INSERT INTO join_table_1 VALUES (2, 'b');\r"
expect "miniob >"
send "INSERT INTO join_table_1 VALUES (3, 'c');\r"
expect "miniob >"
send "INSERT INTO join_table_2 VALUES (1, 2);\r"
expect "miniob >"
send "INSERT INTO join_table_2 VALUES (2, 15);\r"
expect "miniob >"
send "INSERT INTO join_table_3 VALUES (1, 120);\r"
expect "miniob >"
send "INSERT INTO join_table_3 VALUES (3, 800);\r"
expect "miniob >"
send "Select * from join_table_1 inner join join_table_2 on join_table_1.id=join_table_2.id;\r"
expect "miniob >"
send "Select join_table_1.name from join_table_1 inner join join_table_2 on join_table_1.id=join_table_2.id;\r"
expect "miniob >"
send "Select join_table_2.num from join_table_1 inner join join_table_2 on join_table_1.id=join_table_2.id;\r"
expect "miniob >"
send "Select * from join_table_1 inner join join_table_2 on join_table_1.id=join_table_2.id inner join join_table_3 on join_table_1.id=join_table_3.id;\r"
expect "miniob >"
send "Select * from join_table_1 inner join join_table_2 on join_table_1.id=join_table_2.id and join_table_2.num>13 where join_table_1.name='b';\r"
expect "miniob >"
send "Select * from join_table_1 inner join join_table_2 on join_table_1.id=join_table_2.id and join_table_2.num>13 where join_table_1.name='a';\r"
expect "miniob >"
send "Select * from join_table_1 inner join join_table_2 on join_table_1.id=join_table_2.id and join_table_2.num>23 where join_table_1.name='b';\r"
expect "miniob >"
send "select * from join_table_1 inner join join_table_empty_1 on join_table_1.id=join_table_empty_1.id;\r"
expect "miniob >"
send "select * from join_table_empty_1 inner join join_table_1 on join_table_empty_1.id=join_table_1.id;\r"
expect "miniob >"
send "select * from join_table_empty_1 inner join join_table_empty_2 on join_table_empty_1.id = join_table_empty_2.id;\r"
expect "miniob >"
send "select * from join_table_1 inner join join_table_2 on join_table_1.id = join_table_2.id inner join join_table_empty_1 on join_table_1.id=join_table_empty_1.id;\r"
expect "miniob >"
send "select * from join_table_empty_1 inner join join_table_1 on join_table_empty_1.id=join_table_1.id inner join join_table_2 on join_table_1.id=join_table_2.id;\r"
interact